package controllers;

import models.Category;
import service.CategoryInterface;
import service.impl.CategoryImpl;
import utils.JsonUtil;

import java.util.*;

/**
 * 类别action
 */
public class CategoryAction extends Application {

    //获取类别列表
    public static void getCategoryListByPage(String params) throws Exception {
        Map<String, Object> paramsMap = JsonUtil.paseJson2Map(params);
        Integer parentId = (Integer) paramsMap.get("parentCategoryType");
        Integer pageSize = (Integer) paramsMap.get("pageSize");
        Integer pageNum = (Integer) paramsMap.get("pageNum");
        CategoryInterface categoryInterface = new CategoryImpl();
        List<Category> list = categoryInterface.getCategoryListByPage(parentId, pageSize, pageNum);
        renderText(JsonUtil.parseObject(list));
    }
}
